
local basic = require("luaScript.module.common.basic")
local function showDataType()
    local i;
    basic.log_screen("字符串类型", type("hello world"));
    basic.log_screen("方法的类型", type(showDataType));
    basic.log_screen("true的类型", type(true));
    basic.log_screen("整数数字的类型", type(360));
    basic.log_screen("浮点数的类型", type(360.0));
    basic.log_screen("nil的类型", type(nil));
    basic.log_screen("未赋值的类型", type(i));
end

-- 演示数字
local function intPart(number)
    basic.log_screen("演示的整数", number);
    basic.log_screen("向下取整数", math.floor(number));
    basic.log_screen("向上取整数", math.ceil(number));
end

--演示字符串操作
local function stringOperator(s)
    local here = "这里是：".."高性能研习群".."疯狂创客圈";
    print(here);
    basic.log_screen("字符串拼接；"..s);
    basic.log_screen("字符串here的长度"..string.len(here));
    basic.log_screen("字符串here的长度"..#here);
    -- 返回字符串的初始值
    basic.log_screen("字符串查找"..string.find(here,"疯狂创客圈"));
end

-- 正方形类
_Square = {side = 0};
-- table是引用类型
_Square.__index = _Square;
-- 类的方法getArea
function _Square.getArea(self)
    return self.side * self.side;
end

-- 类的new方法
-- 通过:调用，会传递一个self进去
function _Square.new(self, side)
    local cls = {};
    -- 设置cls的元表，如果一个对象的属性找不到，就去它元表的__index属性查找
    setmetatable(cls, self);
    cls.side = side or 0;
    return cls;
end
local _Module = {
    showDataType = showDataType;
    intPart = intPart;
    stringOperator = stringOperator;
    Square = _Square;
}
return _Module